<template>
    <el-dialog
        title="代码生成配置"
        :close-on-click-modal="false"
        width="700px"
        v-model="configDialog.visible"
        @closed="handleDialogClosed">

        <el-form label-width="110px" label-position="right" v-model="geneGlobalConfig">

            <el-form-item label="基础包路径">
                <el-input type="text" placeholder="请输入基础包路径" clearable v-model="geneGlobalConfig.basePackage"/>
            </el-form-item>

            <el-row :gutter="10">
                <el-col :span="12">
                    <el-form-item label="模块名">
                        <el-input type="text" placeholder="请输入模块名" clearable v-model="geneGlobalConfig.moduleName"/>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="实体类包名">
                        <el-input type="text" placeholder="请输入实体类包名" clearable v-model="geneGlobalConfig.entry"/>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="10">
                <el-col :span="12">
                    <el-form-item label="作者名称">
                        <el-input type="text" placeholder="请输入作者名称" clearable v-model="geneGlobalConfig.author"/>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="创建时间">
                        <el-switch v-model="geneGlobalConfig.createTime"/>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="10">
                <el-col :span="6">
                    <el-form-item label="lombok注解">
                        <el-switch v-model="geneModelConfig.lombok"/>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item label="ToString注解">
                        <el-switch v-model="geneModelConfig.toStr"/>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item label="无参注解">
                        <el-switch v-model="geneModelConfig.noArgsConstructor"/>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item label="全参注解">
                        <el-switch v-model="geneModelConfig.allArgsConstructor"/>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="10">
                <el-col :span="6">
                    <el-form-item label="序列化接口">
                        <el-switch v-model="geneModelConfig.serializable"/>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item label="jsonFormat">
                        <el-switch v-model="geneModelConfig.jsonFormat"/>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item label="dateTimeFormat">
                        <el-switch v-model="geneModelConfig.dateTimeFormat"/>
                    </el-form-item>
                </el-col>
            </el-row>

        </el-form>
        <template #footer>
            <el-button type="default" @click="handleDialogBtnCancelClick">取消</el-button>
            <el-button type="primary" @click="handleDialogBtnConfirmClick">修改</el-button>
        </template>
    </el-dialog>
</template>

<script setup>

import {ref} from 'vue'

const configDialog = ref({
    visible: false,
})

const props = defineProps({
    show: {
        default: false,
    }
})

const emits = defineEmits(['update:show'])

watch(() => props.show, val => {
    configDialog.value.visible = val
})

const geneGlobalConfig = ref({
    author: "zhangsan",
    createTime: true,
    basePackage: "com.chenbozhi.template",
    entry: "entry",
    moduleName: ""
})

const geneModelConfig = ref({
    lombok: true,
    toStr: true,
    noArgsConstructor: true,
    allArgsConstructor: true,
    serializable: true,
    jsonFormat: true,
    dateTimeFormat: true
})

const handleDialogClosed = () => {
    emits('update:show', false)
}

const handleDialogBtnConfirmClick = () => {
    emits('update:show', false)
}

const handleDialogBtnCancelClick = () => {
    emits('update:show', false)
}

defineExpose({
    geneGlobalConfig,
    geneModelConfig
})
</script>

<style scoped lang="less">

</style>
